<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加影院</title>
    <script src="../../js/vue.js"></script>
    <script src="../../js/axios0.18.js"></script>
</head>
<body>
<div id="app">
    <form @submit.prevent="submitForm">
        影院名：<input type="text" v-model="cname" required><br/>
        登陆密码：<input type="password" v-model="cpassword" required><br/>
        影院地址：<input type="text" v-model="caddress" required><br/>
        <input type="submit" value="添加">
    </form>
</div>
</body>
</html>
<script>
    new Vue({
        el: "#app",
        data: {
            cname: '',
            cpassword: '',
            caddress: '',
        },
        methods: {
            submitForm() {
                const formData = new FormData();
                formData.append("cinemaName", this.cname);
                formData.append("cinemaPassword", this.cpassword);
                formData.append("cinemaAddress", this.caddress);
                axios.post("http://localhost:8080/ssm/admin/addCinema",
                    formData).then(function (resp) {
                    console.log(resp.data);
                    if (resp.data.code === 200) {
                        alert("添加成功");
                    } else {
                        alert(resp.data.msg);
                    }
                });
            }
        }
    })
</script>
